/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package user_gui;

import java.util.Arrays;
import java.util.Set;
import javax.swing.AbstractListModel;

/**
 *
 * @author Jônatas
 */
public class SetBasedListModel extends AbstractListModel {

    private Set<? extends Object> mySet;

    public SetBasedListModel(Set<? extends Object> mySet) {
        this.mySet = mySet;
    }

    public int getSize() {
        return mySet.size();
    }

    public Object getElementAt(int index) {

        String[] elementos = new String[mySet.size()];

        elementos = mySet.toArray(elementos);

        Arrays.sort(elementos);

        return elementos[index];
    }
}
